package com.peenongsaban.freelance.service;

import com.peenongsaban.freelance.dao.JobManageDAO;
import com.peenongsaban.freelance.dao.impl.JobManageDAOImpl;
import com.peenongsaban.freelance.utils.ConstantUtils;

public class JobManageService {

	public void requestJob(String idCard, String postId, double price) {
		JobManageDAO dao = new JobManageDAOImpl();
		dao.requestJobStatus(idCard, postId, price);
	}

	public void approvedRequestJob(String idCard, String postId) {
		JobManageDAO dao = new JobManageDAOImpl();
		//Owner job approved request
		int requestTypeId = ConstantUtils.STATUS_APPROVED_OF_REQUEST_JOB;
		//Freelane got approved request (A)
		String authorizeStatus = ConstantUtils.STATUS_AUTHORIZE_APPROVED_REQUEST_JOB;
		dao.updateRequestJobStatus(idCard, postId, requestTypeId,
				authorizeStatus);
	}

	public void confirmWorkingJob(String idCard, String postId) {
		//Freelance confirm working job
		int requestTypeId = ConstantUtils.STATUS_WORKING_OF_REQUEST_JOB;
		//Owner got confirm freelance working this job
		String authorizeStatus = ConstantUtils.STATUS_AUTHORIZE_WORKING_JOB;
		JobManageDAO dao = new JobManageDAOImpl();
		dao.updateRequestJobStatus(idCard, postId, requestTypeId,
				authorizeStatus);
	}
	
	public void estimateJob(String idCard, String postId) {
		//After freelance successfully work job. Freelance waiting estimate job
		int requestTypeId = ConstantUtils.STATUS_WAITING_ESTIMATE_OF_REQUEST_JOB;
		//Owner job will must estimate this job
		String authorizeStatus = ConstantUtils.STATUS_AUTHORIZE_ESTIMATE_JOB;
		JobManageDAO dao = new JobManageDAOImpl();
		dao.updateRequestJobStatus(idCard, postId, requestTypeId,
				authorizeStatus);
	}
	
	public void successJob(String idCard, String postId) {
		//After owner job successfully estimate job. Own job click SUCCESS this job
		int requestTypeId = ConstantUtils.STATUS_SUCCESS_OF_REQUEST_JOB;
		//Freelance success job
		String authorizeStatus = ConstantUtils.STATUS_AUTHORIZE_SUCCESS_JOB;
		JobManageDAO dao = new JobManageDAOImpl();
		dao.updateRequestJobStatus(idCard, postId, requestTypeId,
				authorizeStatus);
	}
	

	public void cancelRequestJob(String idCard, String postId) {
		JobManageDAO dao = new JobManageDAOImpl();
		dao.cancelRequestJobStatus(idCard, postId);
	}
	
	
	public void disApprovedRequestJob(String idCard, String postId) {
		JobManageDAO dao = new JobManageDAOImpl();
		//Owner job dis approved request
		int requestTypeId = ConstantUtils.STATUS_DISAPPROVED_OF_REQUEST_JOB;
		//Freelane can't view own job detail 
		String authorizeStatus = ConstantUtils.STATUS_AUTHORIZE_DISAPPROVED_REQUEST_JOB;
		dao.updateRequestJobStatus(idCard, postId, requestTypeId,authorizeStatus);
	}
	
	public void notConfirmedRequestJob(String idCard, String postId) {
		JobManageDAO dao = new JobManageDAOImpl();
		//Owner job dis approved request
		int requestTypeId = ConstantUtils.STATUS_NOT_CONFIRM_OF_REQUEST_JOB;
		//Freelane can't view own job detail 
		String authorizeStatus = ConstantUtils.STATUS_AUTHORIZE_NOT_CONFIRM_JOB;
		dao.updateRequestJobStatus(idCard, postId, requestTypeId,authorizeStatus);
	}
	
	
	
	

}
